{! extends "base.html" !}
{! block hscript !}
	<script type="text/javascript" src="{{site.url}}js/jquery.min.js"></script>
    <script type="text/javascript" src="{{site.url}}js/jquery.form.js"></script>
{! endblock !}
{! block nav !}
			<a href="{{site.adminUrl}}tag">All Tags</a>
{! endblock !}
{! block content !}
<form action="{{site.adminUrl}}tag/update" method="post" id="tagForm">
	<div class="wrap">
<h2>Edit tag</h2>
      <div id="poststuff">

<div id="submitlink" class="submitbox">

<div id="previewview">
</div>

<div class="inside">
<p>&nbsp;</p>
</div>

<p class="submit">
<input type="submit" id="btn-save" tabindex="3" value="Save" name="" class="button button-highlighted"/><br />
<input type="button" id="btn-del" tabindex="4" value="Delete" onclick="doDel({{tag.id}})" class="button button-highlighted"/>
</p>
</div>

<div id="post-body">
<div class="stuffbox">
<h3>Name</h3>
<div class="inside">
	<input type="text" id="name" value="{{tag.name}}" tabindex="1" size="30" name="name"/>
</div>
</div>

<div class="stuffbox">
<h3>Slogan</h3>
<div class="inside">
	<input type="text" id="slogan" value="{{tag.slogan}}" tabindex="2" size="30" name="slogan"/>
</div>
</div>

<input type="hidden" value="{{tag.id}}" name="id"/>

</div>
</div>	
	</div>
</form>
{! endblock !}
{! block bscript !}    
<script type="text/javascript">
    $(document).ready(function() { 
    	var options = {
    	    	dataType: 'json',
    	    	success : function(data) {
	    				var hmd = $("#hiddenMessage");
	    				if (data.type == "error") {
	    					hmd.html("<div class='error'>" + data.message + "</div>");
	    				} else {
	    					hmd.html("<div class='info'>" + data.message + "</div>"); 
	    				}
	    				hmd.show().focus();
    				},
    	};
    	$("#tagForm").ajaxForm(options);
    });

    function doDel(id) {
     	$.ajax({
     		type: "GET",
     		url: "{{site.adminUrl}}tag/delete?id=" + id,
     		dataType: "json",
     		success: function(data){
     			var hmd = $("#hiddenMessage");
    	    	if (data.type == "error") {
    	    		hmd.html("<div class='error'>" + data.message + "</div>");
    	    	} else {
    	    		hmd.html("<div class='info'>" + data.message + "</div>");
    	    	}
    	    	hmd.show().focus();
    	    	$("#btn-save").hide();
    	    	$("#btn-del").hide();
     		}
     	});
    }    
</script>
{! endblock !}